function map=rainbow(number)

  if (number == 1)
    map = [1, 0, 0];  
  elseif (number > 1)
    x = linspace (0, 1, number)';
    r = (x < 2/5) + (x >= 2/5 & x < 3/5) .* (-5 * x + 3) + (x >= 4/5) .* (10/3 * x - 8/3);
    g = (x < 2/5) .* (5/2 * x) + (x >= 2/5 & x < 3/5) + (x >= 3/5 & x < 4/5) .* (-5 * x + 4);
    b = (x >= 3/5 & x < 4/5) .* (5 * x - 3) + (x >= 4/5);
    map = [r, g, b];
  else
    map = [];
  end % if
  
  map(:,:) = uint8( map(:,:) * 255 );

  end % function